<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="author" content="https://blog.csdn.net/q475254344" />
    <title>Title</title>
    <link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}">
<!--    <link rel="stylesheet" th:href="@{/css/talk_1.css}">-->
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script th:src="@{/js/jquery-3.1.1.min.js}"></script>
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
</head>
<body>


<!--菜单-->
<ul class="layui-nav layui-bg-blue" lay-filter="">
    <li class="layui-nav-item "><a href="/" style="font-size: 20px">首页</a></li>
    <li class="layui-nav-item">
        <a href="javascript:;" style="font-size: 20px">习题库</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{/item/chapter/overview}">分章节练习</a>
            </dd>
            <dd>
                <a th:href="@{/item/overview}">分题型练习</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item">
        <a href="javascript:;" style="font-size: 20px">课程分类</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{'/course/type_show/'+${coursetype.getId()}}" th:each="coursetype:${coursetypes}" th:text="${coursetype.getCourse_name()}"></a>
            </dd>
            <dd>
                <a th:href="@{/course/type_show/0}" >全部课程</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} == null"><a th:href="@{/community/index}" style="font-size: 20px">社区</a></li>
    <li class="layui-nav-item " th:if="${session.loginuser} != null">
        <a href="javascript:;" style="font-size: 20px">社区</a>
        <dl class="layui-nav-child">
            <dd><a th:href="@{/community/index}">社区首页</a></dd>
            <dd><a th:href="@{/stu/community/commenting}">发布话题</a></dd>
            <dd><a th:href="@{/stu/community/management}">我的话题</a></dd>
            <dd><a th:href="@{/stu/chat_all}" target="_blank">头脑风暴</a></dd>
        </dl>
    </li>
    <li class="layui-nav-item layui-this"><a th:href="@{/file/list}" style="font-size: 20px">资料干货</a></li>

    <!--如果没有登录-->
    <li class="layui-nav-item" th:if="${session.loginuser} == null">
        <a th:href="@{/login}" style="font-size: 20px">登录</a>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} == null">
        <a th:href="@{/register}" style="font-size: 20px">注册</a>
    </li>
    <!--如果没有登录-->

    <!--如果登录-->
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <a href="javascript:;" style="font-size: 20px">我的班级</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{/stu/map/show}">班级签到</a>
            </dd>
            <dd>
                <a th:href="@{/stu/exam/overview}">班级考试</a>
            </dd>
            <dd>
                <a th:href="@{/stu/exam/mydegree/list}">我的考试成绩</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <a href="javascript:;" style="font-size: 20px">好友管理</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd>
                <a th:href="@{/stu/friends/list}">好友列表</a>
            </dd>
            <dd>
                <a th:href="@{/stu/friends/search}">搜索好友</a>
            </dd>
        </dl>
    </li>
    <li class="layui-nav-item" th:if="${session.loginuser} != null">
        <img th:src="@{'/show/'+${session.loginuser.getId()}}" class="layui-nav-img">[[${session.loginuser.username}]]
        <dl class="layui-nav-child">
            <dd><a th:href="@{/stu/center}">个人中心</a></dd>
            <dd><a th:href="@{/stu/logout}">退出</a></dd>
        </dl>
    </li>

    <!--如果登录-->
</ul>
<!--菜单-->

<div class="layui-card">
    <div class="layui-card-header">
<div class="demoTable">

    <div class="layui-inline">
        <input class="layui-input"  id="share_name" autocomplete="off" placeholder="搜索分享者">
    </div>
    <div class="layui-inline">
        <input class="layui-input"  id="file_name" autocomplete="off" placeholder="搜索文件名">
    </div>
    <button class="layui-btn" data-type="reload" id="search">搜索</button>
</div>
    </div>

    <div class="layui-card-body">
<table class="layui-table" lay-filter="demo" id="test1">
    <thead>
    <tr>
        <th lay-data="{field:'username', width:500}">文件名</th>
        <th lay-data="{field:'id', width:100, sort:true}">分享者</th>
        <th lay-data="{field:'sign',sort:true}">上传时间</th>
        <th lay-data="{field:'click',sort:true}">点击量</th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="file:${files}">
        <td >
            <button   th:onclick="|praise(${file.getId()})|" >
                <a  th:href="'https://wk2020.oss-cn-shenzhen.aliyuncs.com/'+${file.getPath()}" target="_blank" th:text="${file.getName()}"></a>
                <i class="layui-icon layui-icon-download-circle"></i>
            </button>
        </td>
        <td th:text="${file.getUsername()}"></td>
        <td th:text="${#dates.format(file.getCreatetime(),'yyyy年MM月dd日')}"></td>
        <td th:text="${file.getClick()}"></td>
    </tr>
    </tbody>
</table>
    </div>
</div>

<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
    layui.use('table', function(){
        var table = layui.table;
        //第一个实例
        //转换静态表格
        table.init('demo', {
            // height: 500 //设置高度
            limit: 11 //注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
            //支持所有基础参数
            ,page: true //开启分页
        });
    });
//增加下载量
    function praise(id)
    {
        $.post(
            '/file/praise',
            {'id':id},
            function (result) {

            }
        )
    }
    $(document).ready(function () {
        $('#search').click(function () {
            var show_name=$('#share_name').val();
            var file_name=$('#file_name').val();
            location.href = '/file/list?username=' + show_name +'&file_name=' + file_name;
        });
    })
</script>
</body>
</html>